<?php
/** 
 * Created by RisingSun. 
 * User: MarkSpace 
 * Date: 20210822
 * Time: 11:05 
 * 链接管理
 */
namespace ms\home;

use ms\home\Model;
// use ms\core\Page;

class Partner extends Model{

	private $links = 'website_links';
    private $linksclass = 'website_linksclass';
    
    
    /**
     * 链接列表
     * @param array $linkslist
     * @param array $where
     */
    public function linkslist($where='',$page=1,$page_size=10,$file='*')
    {
        $linkslist = Model::name($this->links)
            ->field($file)
            ->where($where)
            ->limit(($page-1)*$page_size,$page_size)
            ->order('sortid desc')
            ->select();
        return $linkslist;
    }

    /**
     * 链接列表
     * @param array $indexlinks
     * @param array $where
     */
    public function indexlinks($where='',$page=1,$page_size=10)
    {
        $indexlinks = Model::name($this->links)
            ->alias('a')
            ->joinp($this->linksclass.' as b','a.cid=b.id','left')
            ->field('a.*,b.title as ltitle,b.logimg,b.mlogimg')
            ->where($where)
            ->limit(($page-1)*$page_size,$page_size)
            ->order('sortid desc')
            ->select();
        return $indexlinks;
    }

    /**
     * 链接詳情
     * @param array $links
     * @param array $where 
     */ 
    public function links($where='',$file='*')
    {
    $links = Model::name($this->links)
            ->field($file)
            ->where($where)
            ->order('id desc')
            ->find();
        return $links;
    }

    /**
     * 链接分组列表
     * @param array $linksclasslist 
     * @param array $where 
     */ 
    public function linksclasslist($where='',$page=1,$page_size=10,$file='*')
    {
    $linksclasslist = Model::name($this->linksclass)
            ->field($file)
            ->where($where)
            ->limit(($page-1)*$page_size,$page_size)
            ->order('orderid desc')
            ->select();
        return $linksclasslist;
    }

    /**
     * 链接分组
     * @param array $linkscate 
     * @param array $where 
     */ 
    public function linkscate($where='',$file='*')
    {
    $linkscate = Model::name($this->linksclass)
            ->field($file)
            ->where($where)
            ->find();
        return $linkscate;
    }

}
